﻿package com.xuanyuan.Interceptor;

import java.util.Map;

import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


@Component("LoginInterceptor")
public class LoginInterceptor extends AbstractInterceptor{

		@Override
		public String intercept(ActionInvocation invocation) throws Exception {
			
			System.out.println("-----------------");
////			System.out.println("invocation.getInvocationContext().getName()"+invocation.getInvocationContext().getName());
////			System.out.println("invocation.getProxy().getNamespace()"+invocation.getProxy().getNamespace());
//			// TODO Auto-generated method stub
			ActionContext ctx = invocation.getInvocationContext();
			Map session = ctx.getSession();
			//Object user=session.get("user");
			if(session.get("userName")==null)
			{
				return "login";
			}else {
				return invocation.invoke();
			}
		}
		
}
